package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.Category;
import org.apache.ibatis.annotations.*;
import org.springframework.boot.web.servlet.ServletComponentScan;

import java.util.List;

/**
 * @author 听雨楼
 */
@Mapper
public interface CategoryMapper {
    //改造后的list方法！

    /**
     *
     * @param categoryId
     * @return
     */
    @Select("select *from category where id=#{categoryId};")
    Category findByCategoryId(Long categoryId);

    List<Category> findPage(Integer page, Integer pageSize);
    @Insert("insert into category values(null,#{type},#{name},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser});")
    void save(Category category);
    @Delete("delete from category where id=#{id};")
    void delete(Long id);
    @Update("update category set name=#{name},sort=#{sort},update_time=#{updateTime},update_user=#{updateUser} where id=#{id}")
    void update(Category category);

    List<Category> findByType(@Param("type") Integer type);

    @Select("select *from category where id=#{id};")
    Category findById(Long categoryId);
}
